<?php

namespace SummoIngenio\Sai\MatematicaBundle\Utility\Juego\P0;
use SummoIngenio\Sai\MatematicaBundle\Utility\Juego\JuegoBase;
define('CANT_PROBLEMAS', 5);
/**
 * Description of P01038
 *
 * @author SVM
 */

class P01038 extends JuegoBase {
  
  public function init() {
	$r1 = array(11,12,13,14,15,16,17,18,19,20);
	$r2 = array(11,12,13,14,15,16,17,18,19);
	shuffle($r1);
	shuffle($r2);	
	$sg = rand(1,2);
	if($sg==1){
		$this->sig = '+';	
	}else{
		$this->sig = '-';
	}
	
	$this->rrest1 = $r2[0];
	$this->rrest2 = $r2[1];	
	if($this->sig == '+'){
		$this->op1 = rand(10,19);
		$this->op2 = rand(1,20-$this->op1);
	}else{
		$this->op2 = rand(1,20-$this->rrest1);
		$this->op1 = $this->rrest1+$this->op2;		
	}
	
  }
  
  public function getPregunta() {
    return '';
  }
  public function getHtmlDesactivado() {	
    return $this->render('P0/P01038/desactivado', array(
        'op1'   =>  $this->op1,		
        'op2'   =>  $this->op2,
        'sig'   =>  $this->sig,
      ));
  }
  
  public function getHtmlJugable() {
    return $this->render('P0/P01038/jugable', array(
        'op1'   =>  $this->op1,		
        'op2'   =>  $this->op2,
        'sig'   =>  $this->sig,	
      ));
  }
  
  public function getHtmlResuelto() {
    return $this->render('P0/P01038/resuelto', array(
        'op1'   =>  $this->op1,		
        'op2'   =>  $this->op2,
        'sig'   =>  $this->sig,	
      ));
  }
  
  public function verificarRespuesta($respuestaUsuario) {
     $rsp = true;
	 $cadena1 = $this->op1+$this->sig+$this->op2+"="+$respuestaUsuario->get('valor1')+",";
     $cadena = $cadena1;
	 if($this->sig == '+'){
		 if($respuestaUsuario->get('valor1')!=$this->op1+$this->op2){ 
		   $rsp=false;
		 }	 	 
	 }else{
		 if($respuestaUsuario->get('valor1')!=$this->op1-$this->op2){ 
		   $rsp=false;
		 }		 
	 }
    $aRetornar = array(
      'respuesta' => $cadena,
      'correcta'  => $rsp,
    );
    return $aRetornar;
  }

  public function getJavascript() {
    $aRetornar = array(
      "tipo"      => "archivo",
      "contenido" => "P0/P01038.js"
    );
    return $aRetornar;
  }

  public function getCss() {
    $aRetornar = array(
      "tipo"      => "archivo",
      "contenido" => "P0/P01038.css"
    );
    return $aRetornar;
  }

  public function __sleep() {
    return array(
        'op1',		
        'op2',
		'sig',
    );
  }
}

?>